DATA TYPES in C

 DATA TYPES

Any programming language's fundamental units are data types, which offer a structure for arranging, modifying, and storing data. Primitive, derived, and user-defined data types are the three primary categories of data types in C programming, each with a different function and differing degrees of complexity.


Three types of data types in C

  1. Primitive Data type

  2. Derived Data type

  3. User-defined Data type






a) Primitive data type:

These are the fundamental data types that the C language uses, providing the bare minimum in terms of manipulation and storage. Among them are:


 i. Integer - used for storing full numbers devoid of decimal places. Integers come in different sizes (e.g., int, short, long) and can be signed or unsigned.

ii. Floating-point/Double - aimed for storing fractional components of decimal values. Compared to float, double gives more precision.

iii. Boolean - symbolizes logical values, which are often expressed as true or false, 1 or 0, to represent the outcome of a logical operation.
iv.  Character - used to hold single letters or characters that are usually encoded in ASCII or Unicode.


b) Derived Data types:

These data types offer enhanced data organizing and manipulation capabilities and are descended from simpler data types. Among them are:


i. Array - a group of exactly the same formatted elements retrieved using an index and placed in consecutive memory regions.

ii. Pointers - variables that hold memory addresses, allowing indirect data processing and dynamic memory allocation.


c) User-defined data types:

The programmer creates these data types, which provide flexibility in constructing data structures that meet particular needs. Among them are:


i. Structure - makes it possible to combine several variables of various data kinds under one name, which makes it easier to create complicated data structures.

ii. Union - Comparable to structures, but sharing memory space among its members and only able to hold one value at a time.
iii. Enumeration - makes it possible to create user-defined data types with a limited number of named values, which enhances the readability and maintainability of code.
iv. Typedef - permits the mixing of pre-existing data types with user-specified names, improving the portability and clarity of the code.

Post a Comment

0 Comments